@use "sass:math";
@import "mixins/mixins";
@import "common/var";

@include b(badge) {
  position: relative;
  vertical-align: middle;
  display: inline-block;

  @include e(content) {
    background-color: getProp("badge-background-color");
    border-radius: getProp("badge-radius");
    color: getProp("color-white");
    display: inline-block;
    font-size: getProp("badge-font-size");
    height: getProp("badge-size");
    line-height: getProp("badge-size");
    padding: 0 getProp("badge-padding");
    text-align: center;
    white-space: nowrap;
    border: 1px solid getProp("color-white");

    @include when(fixed) {
      position: absolute;
      top: 0;
      right: #{1 + math.div($--badge-size, 2)};
      transform: translateY(-50%) translateX(100%);

      @include when(dot) {
        right: 5px;
      }
    }

    @include when(dot) {
      height: 8px;
      width: 8px;
      padding: 0;
      right: 0;
      border-radius: 50%;
    }

    @each $type in (primary, success, warning, info, danger) {
      @include m($type) {
        @if $type == primary {
          background-color: $--color-primary;
        } @else if $type == success {
          background-color: $--color-success;
        } @else if $type == warning {
          background-color: $--color-warning;
        } @else if $type == info {
          background-color: $--color-info;
        } @else {
          background-color: $--color-danger;
        }
      }
    }
  }
}
